package com.flower.controller;

import com.flower.model.entity.Adminlogin;
import com.flower.result.PageResult;
import com.flower.result.Result;
import com.flower.service.IAdminloginService;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author lm
 * @create 2022-03-17 16:29
 */
@RestController
@RequestMapping("/adminlogin")
public class AdminloginController {

    @Autowired
    private IAdminloginService adminloginService;


    //新增和修改
    @PostMapping
    public Result save(@RequestBody Adminlogin adminlogin) {
        adminloginService.saveOrUpdate(adminlogin);
        //新增或者更新
        return Result.success("操作成功");

    }

    //查询所有数据
    @GetMapping("/")
    public Result findAll() {
        return Result.success(adminloginService.list());
    }


    //分页查询——mybatis-plus的方式查询
    @GetMapping("/page")
    public Result<PageResult> findPage(@RequestParam Integer pageNum,
                                       @RequestParam Integer pageSize

    ) {
        return Result.success(adminloginService.page(pageNum, pageSize));
    }

}
